package com.order.controller;

import com.common.entity.OrderShop;
import com.common.untils.CommonResult;
import com.order.service.IOrderShopService;
import com.order.vo.OrderShopVo;
import com.order.vo.UserOrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xdl
 * @since 2022-09-03
 */
@RestController
@RequestMapping("/order/orderShop")
public class OrderShopController {
    @Autowired
    private IOrderShopService iOrderShopService;
    //订单点击详情
    @PostMapping("orderDetail/{id}")
    public CommonResult findAllDetail(@PathVariable String id){
        return iOrderShopService.findAllDetail(id);
    }
    //用户订单管理
    @PostMapping("orderShop")
    public CommonResult orderShop(@RequestBody OrderShopVo orderShopVo, HttpServletRequest request){
        String homeToken = request.getHeader("homeToken");
        return iOrderShopService.orderShop(orderShopVo,homeToken);
    }

    //查询未支付订单
    @PostMapping("userOrder02")
    public CommonResult userOrder02(@RequestBody UserOrderVo userOrderVo,HttpServletRequest request){
        System.out.println(userOrderVo);
        String homeToken = request.getHeader("homeToken");
        return iOrderShopService.userOrder02(userOrderVo,homeToken);
    }
}
